package game.scene.sceneobject;

import common.Coordinate;
import common.Rectangle;

import engine.video.blit.Blitter;
import engine.video.blit.SpriteInfo;

public class Sprite_SO extends SceneObject_A {
	public Coordinate Location;
	public SpriteInfo Sprite;
	public Sprite_SO(SpriteInfo sprite) {
		Sprite = sprite;
		Location = new Coordinate();
	}
	@Override
	public void setLocation(Coordinate location) {
		Location.X = location.X;
		Location.Y = location.Y;
		
		if(Sprite.Offset == null) {
			this.VisRect.X = Location.getX();
			this.VisRect.Y = Location.getY();
		} else {
			this.VisRect.X = Sprite.Offset.getX() + Location.getX();
			this.VisRect.Y = Sprite.Offset.getY() + Location.getY();
		}
	}
	
	@Override
	public void setBoundry(Rectangle bounds) {
		return;
	}
	
	@Override
	public boolean isOverlapping(Rectangle queryRect) {
		return this.VisRect.overlaps(queryRect);
	}

	@Override
	public void render(Coordinate camera, Blitter blitter) {
		blitter.blit(Sprite, Location.getX() - camera.getX(), Location.getY() - camera.getY());
	}
	
}
